IBM6250 Group Project - Coffee Vending

Group 1

Introduction

Effective inventory control for coffee-vending machines hinges on anticipating weekly ingredient consumption while avoiding costly spoilage. We forecast demand using historical sales from two machines, delivering eight-week projections that guide stock levels and reorder cadence.

This report:

  1. Imports & cleans transaction data from two coffee-vending machines.
  2. Explores key demand drivers.
  3. Models weekly sales with Seasonal ARIMA (plus Prophet as a benchmark).
  4. Delivers eight-week forecasts and stocking recommendations.

Data Input and Combining

Kaggle data is from two vending machines. Below we will import the two datasets and combine them.

Transaction Data

Products and Ingredients

In the dataset, only product names are given. In order to more accurately predict what ingredients are needed and when, we must decompose the product into its ingredients. See below for the assumptions made for each of the 33 unique products.

Combining Transaction Data and Recipies

Below we will join the two tables on the coffee name, which will add ingredients to all rows in the transaction data. Explore the data we will use in our analysis below:

Converting to Weekly Series

We aggregate to a weekly time series because the business decisions we are informing, like re-ordering coffee, milk, chocolate, etc, are made on a weekly cadence. Collapsing daily transactions into weeks smooths out erratic, day-to-day swings leaving a cleaner signal that aligns directly with the quantity we must predict.

We will also convert to a time series type object and verify it has no gaps in the series. If we see FALSE from .gaps, then we have no gaps.

# A tibble: 1 × 1
  .gaps
  <lgl>
1 FALSE

Final Data for use in Analysis

# 1. Reshape to long format: one row per week-metric pair -------------
weekly_long <- weekly_sales |>
  pivot_longer(
    cols      = coffee:sales_n,   # everything after the 'week' column
    names_to  = "metric",
    values_to = "value"
  )

# 2. Build the interactive plot --------------------------------------
plot_ly(
  data  = weekly_long,
  x     = ~week,
  y     = ~value,
  color = ~metric,
  type  = "scatter",
  mode  = "lines+markers",
  hovertemplate = paste(
    "<b>%{x|%Y-%m-%d}</b><br>",
    "%{text}: %{y}<extra></extra>"
  ),
  text = ~metric
) %>% 
  layout(
    hovermode = "x unified",
    legend    = list(title = list(text = "Metric")),
    yaxis     = list(title = "Units"),
    xaxis     = list(title = "Week")
  )

Weekly ingredient demand vs. cups sold